#pragma indent
using NemerleUnit
using Nemerle.Collections
using System.Diagnostics
using System.IO
using Nemerle.IO

test "acceptance test"
    _ = Directory.CreateDirectory("TestBin\\UnitTests")
    try
        File.Copy("TestData\\Module.py", "TestBin\\Module.py")
        File.Copy("TestData\\UnitTests\\ModuleTest.py", "TestBin\\UnitTests\\ModuleTest.py")
        def p = Process()
        p.StartInfo.FileName = "splitcamelcase.exe"
        p.StartInfo.Arguments =  "TestBin\\UnitTests\\ModuleTest.py"
        p.StartInfo.UseShellExecute = false
        _ = p.Start()
        p.WaitForExit()
        def expect = File.ReadAllText("TestData\\UnitTests\\expected_ModuleTest.py")
        def actual = File.ReadAllText("TestBin\\UnitTests\\ModuleTest.py")
        assert actual equals expect
    finally
        Directory.Delete("TestBin", true)

test "take first 4 components"
    assert SplitCamelCase.First4Components("testVeryImportantMethod") equals "testVeryImportantMethod"
    assert SplitCamelCase.First4Components("test_veryImportantMethod") equals "test_veryImportantMethod"
    assert SplitCamelCase.First4Components("testVeryImportantMethodDoesTheRighJob") equals "testVeryImportantMethod"
    assert SplitCamelCase.First4Components("testMethod") equals "testMethod"

setup
    def verify_split(input, expectedOutput, dictionary=Hashtable())
        def actualOutput = SplitCamelCase.Split(input, dictionary)
        assert actualOutput equals expectedOutput


test "simple case"
    verify_split("testOneTwoThree", "test one two three")

test "preserving known words"
    verify_split("testGetUnderlyingProcessReturnsTrue", 
                "test getUnderlyingProcess returns true",
                Hashtable([("getunderlyingprocess", "getUnderlyingProcess")]))

test "camelcase mixed with underscores"
    verify_split("testMethod_returnsTrue",
                "test method _returns true")

test "method starting with underscore"
    verify_split("test_getSthFromSomebody",
                "test _getSthFromSomebody",
                Hashtable([("_getsthfromsomebody", "_getSthFromSomebody")]))

test "number of components"
    assert SplitCamelCase.NumberOfComponents("testShortTestName") equals 4
    assert SplitCamelCase.NumberOfComponents("testThreeComponents") equals 3

